﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NCS.IConnect.ApplicationContexts;
using Microsoft.SharePoint;
using JM.JCY.Common;

namespace NCS.OCP.SharePointComponent.Newsfeed.SiteNewsfeed
{
    public partial class SiteNewsfeedUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                SPWeb CurrentWeb = SPContext.Current.Web;
                if (CurrentWeb.ServerRelativeUrl.Equals("/"))
                {
                    ApplicationContext.Current.SetKeyValue("NewsfeedAppType", JCYConstant.PhotoAlbum.ApplicationTypeName.PublicName);
                    ApplicationContext.Current.SetKeyValue("NewsfeedAppId", "0");
                }
                else if (CurrentWeb.ServerRelativeUrl.Equals("/PersonalSite"))
                {
                    ApplicationContext.Current.SetKeyValue("NewsfeedAppType", JCYConstant.PhotoAlbum.ApplicationTypeName.PersonalName);
                    ApplicationContext.Current.SetKeyValue("NewsfeedAppId", ApplicationContext.Current.GetKeyValue("userId").ToString());
                }
                else if (CurrentWeb.ServerRelativeUrl.Equals("/MyDept"))
                {
                    ApplicationContext.Current.SetKeyValue("NewsfeedAppType", JCYConstant.PhotoAlbum.ApplicationTypeName.WorkgroupName);
                    if (Request.Params["DeptId"] != null && Request.QueryString["DeptId"] != "")
                    {
                        ApplicationContext.Current.SetKeyValue("NewsfeedAppId", Request.QueryString["DeptId"]);
                    }
                }
                else if (CurrentWeb.ServerRelativeUrl.Equals("/MyCommittee"))
                {
                    ApplicationContext.Current.SetKeyValue("NewsfeedAppType", JCYConstant.PhotoAlbum.ApplicationTypeName.CommitteeName);
                    if (Request.Params["CommitteeId"] != null && Request.QueryString["CommitteeId"] != "")
                    {
                        ApplicationContext.Current.SetKeyValue("NewsfeedAppId", Request.QueryString["CommitteeId"]);
                    }
                }
            }
        }
    }
}
